/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.edu.flf.audioteca.entidades;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Nathan Azevedo
 */
@Entity
@Table(name = "tb_emprestimos")
@NamedQueries({@NamedQuery(name = "Emprestimo.findAll", query = "SELECT e FROM Emprestimo e"), @NamedQuery(name = "Emprestimo.findByIdUsuarioFk", query = "SELECT e FROM Emprestimo e WHERE e.emprestimoPK.idUsuarioFk = :idUsuarioFk"), @NamedQuery(name = "Emprestimo.findByIdCdFk", query = "SELECT e FROM Emprestimo e WHERE e.emprestimoPK.idCdFk = :idCdFk"), @NamedQuery(name = "Emprestimo.findByDtRetirada", query = "SELECT e FROM Emprestimo e WHERE e.dtRetirada = :dtRetirada"), @NamedQuery(name = "Emprestimo.findByDtDevolucao", query = "SELECT e FROM Emprestimo e WHERE e.dtDevolucao = :dtDevolucao")})
public class Emprestimo implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected EmprestimoPK emprestimoPK;
    @Column(name = "dt_retirada")
    @Temporal(TemporalType.DATE)
    private Date dtRetirada;
    @Column(name = "dt_devolucao")
    @Temporal(TemporalType.DATE)
    private Date dtDevolucao;

    public Emprestimo() {
    }

    public Emprestimo(EmprestimoPK emprestimoPK) {
        this.emprestimoPK = emprestimoPK;
    }

    public Emprestimo(int idUsuarioFk, int idCdFk) {
        this.emprestimoPK = new EmprestimoPK(idUsuarioFk, idCdFk);
    }

    public EmprestimoPK getEmprestimoPK() {
        return emprestimoPK;
    }

    public void setEmprestimoPK(EmprestimoPK emprestimoPK) {
        this.emprestimoPK = emprestimoPK;
    }

    public Date getDtRetirada() {
        return dtRetirada;
    }

    public void setDtRetirada(Date dtRetirada) {
        this.dtRetirada = dtRetirada;
    }

    public Date getDtDevolucao() {
        return dtDevolucao;
    }

    public void setDtDevolucao(Date dtDevolucao) {
        this.dtDevolucao = dtDevolucao;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (emprestimoPK != null ? emprestimoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Emprestimo)) {
            return false;
        }
        Emprestimo other = (Emprestimo) object;
        if ((this.emprestimoPK == null && other.emprestimoPK != null) || (this.emprestimoPK != null && !this.emprestimoPK.equals(other.emprestimoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.edu.flf.audioteca.entidades.Emprestimo[emprestimoPK=" + emprestimoPK + "]";
    }

}
